<?php
namespace Home\Controller;
use Common\Controller\HomeController;
class IndexController extends HomeController {

    public function __init(){
        $headConfig = [
          'css' => ['index.min'],
          'js' => ['home.min'],
          'title' => '小麦商城',
        ];
        $this->assign('headConfig',$headConfig);
    }
    public function index(){
        // 获得购物车里的商品信息
        $cartData = $_SESSION['cart'];
        foreach($cartData['goods'] as $k => $v){
            $cartData['goods'][$k]['good'] = M("Goods")->where("gid = {$v['id']}")->find();
            $cartData['goods'][$k]['info'] = $v['name'];
            foreach($v['options'] as $kk => $vv){
                $cartData['goods'][$k]['info'] .= $vv;
            }
        }
        if($cartData){
//            dd($cartData);
            $this->assign("cartData",$cartData);
        }
        $this->display();
    }
}